#include "e.h"
#include "e_mod_main.h"
#include "compiz.h"



int
allocatePrivateIndex (int		  *len,
		      char		  **indices,
		      ReallocPrivatesProc reallocProc,
		      void		  *closure)
{
    char *newIndices;
    int  i;

    for (i = 0; i < *len; i++)
    {
	if (!(*indices)[i])
	{
	    (*indices)[i] = 1;
	    return i;
	}
    }

    newIndices = (char *) realloc (*indices, (*len + 1) * sizeof (char));
    if (!newIndices)
	return -1;

    newIndices[*len] = 1;
    *indices = newIndices;

    if (!(*reallocProc) (*len + 1, closure))
	return -1;

    return (*len)++;
}

void
freePrivateIndex (int  len,
		  char *indices,
		  int  index)
{
    if (index < len)
	indices[index] = 0;
}
